
const { createWebAPIRequest } = require('../../util/util')
module.exports = [
  {
    /**
    * @api {get} /music/daily/signin [签到]
    * @apiGroup Music
    * @apiPermission none
    * @apiDescription 需要登录
    * @apiParam {Number} [type=0]  0为安卓端签到 3点经验,1为网页签到,2点经验
    * @apiSuccess {Object} android 三种结果
    * @apiSuccessExample {json} Success-Response:
    *     HTTP/1.1 200 OK
    *     {'point': 3, 'code': 200}, 'web': {'point': 2, 'code': 200}}
    *     {'point': 3, 'code': 200}, 'web': {'point': 2, 'code': 200}}
    *     {'code': 301}, 'web': {'code': 301}}
    */
    url: '/music/daily/signin',
    request: (req, res) => {
      const cookie = req.get('Cookie') || ''
      let type = req.query.type || 0 // 0为安卓端签到 3点经验,1为网页签到,2点经验
      const data = {
        csrf_token: '',
        type
      }
      // {'android': {'point': 3, 'code': 200}, 'web': {'point': 2, 'code': 200}}
      // {'android': {'code': -2, 'msg': '重复签到'}, 'web': {'code': -2, 'msg': '重复签到'}}
      // 'android': {'code': 301}, 'web': {'code': 301}}

      createWebAPIRequest(
        'music.163.com',
        '/weapi/point/dailyTask',
        'POST',
        data,
        cookie,
        musicReq => res.send(musicReq),
        err => res.status(500).send({err})
      )
    }
  }
]
